package com.ssm.controller.teacher;

import com.ssm.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
public class TeacherHomeController extends BaseController {
    //转到后台管理-主页
    @RequestMapping(value = "teacher/home",method = RequestMethod.GET)
    public String goToPage(HttpSession session, Map<String,Object> map){
        logger.info("检查教师权限");
        String teacherId=checkAdmin(session);
        if (teacherId.equals("teacherId")){
            return "teacher/homePage";
        }
        return "redirect:/";
    }
    @RequestMapping(value = "teacher/account/logout",method = RequestMethod.GET)
    public String logout(HttpSession session) {
        logger.info("检查管理员权限");
        String adminId=checkAdmin(session);
        if (adminId.equals("teacherId")){
            session.removeAttribute("teacherId");
            session.invalidate();
            logger.info("登录信息已清除，返回登录页");
            return "redirect:/";
        }
        return "redirect:/";
    }

}
